/*
 * Copyright (c) JiaChaoYang 2023-7-27 MongoPlus版权所有
 * 适度编码益脑，沉迷编码伤身，合理安排时间，享受快乐生活。
 * email: j15030047216@163.com
 * phone: 15030047216
 * weChat: JiaChaoYang_
 */

package com.mongoplus.solon.entity;

import com.mongoplus.annotation.ID;
import com.mongoplus.annotation.collection.CollectionField;
import com.mongoplus.annotation.collection.CollectionName;
import com.mongoplus.annotation.index.MongoIndex;
import com.mongoplus.annotation.index.MongoTextIndex;
import com.mongoplus.enums.IdTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@CollectionName("test_user")
@MongoTextIndex(fields = "userAddress")
public class User {

    @ID(type = IdTypeEnum.AUTO)
    private String userId;

    @CollectionField("userName")
    private String userName;

    private String userAddress;

    private Integer userAge;

    private Long userStatus;

    private LocalDateTime createTime;

    // 这里利用MongoDB的TTL索引，当过期时MongoDB会自动删除过期的数据，同时如果timeout如果为null那么视为永不删除
    @MongoIndex(expireAfterSeconds = 0, background = true)
    private LocalDateTime timeout;

}

